package com.tkm.types.classes

//  定义类，默认为public
class SimpleClass(val x: Int, val y: String, override val simpleProperty: Int)
    : AbsClass(), SimpleInf {

    fun y() {
        println("SimpleClass y")
    }

    fun zzz() {
        println("SimpleClass ZZZ!")
    }

    override fun simpleMethod() {
        println("SimpleClass simpleMethod")
    }

    override fun absMethod() {
        println("SimpleClass absMethod")
    }
}

class SimpleClass2(val name: String, val age: Int)
    : SimpleInf {

    override val simpleProperty: Int
        get() = age + 100

    override fun simpleMethod() {
        println("SimpleClass2 simpleMethod")
    }

    //  默认就是final，即子类不可再重写
    override fun simpleMethod2() {
        println("SimpleClass2 simpleMethod2")
    }
}

fun main() {
    //  实例化类
    val simpleClass = SimpleClass(1, "S", 100)
    println(simpleClass.x)
    println(simpleClass.y)
    println(simpleClass.simpleProperty)
    simpleClass.y()
    simpleClass.zzz()
    simpleClass.absMethod()
    simpleClass.nonOverridable()
    simpleClass.simpleMethod()
    simpleClass.simpleMethod2()

    val simpleClass2 = SimpleClass2("TKM", 24)
    println(simpleClass2.name)
    println(simpleClass2.age)
    println(simpleClass2.simpleProperty)
    simpleClass2.simpleMethod()
    simpleClass2.simpleMethod2()
}
